package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.Comment;
import cn.tedu._04mybatis.pojo.CommentVO1;
import cn.tedu._04mybatis.pojo.CommentVO2;
import cn.tedu._04mybatis.pojo.UserVO2;
import org.apache.ibatis.annotations.*;

@Mapper
public interface CommentMapper {
    @Insert("insert into comment(content,created,weibo_id,user_id) " +
            "values (#{content},#{created},#{weiboId},#{userId})")
    int insertComment(Comment comment);

    @Delete("delete from comment " +
            "where user_id = #{userId}")
    int deleteByUserId(Integer id);

    @Update("update comment set content=#{content},created=#{created},weibo_id=#{weiboId},user_id=#{userId} " +
            "where id = #{id}")
    int updateById(Comment comment);

    @Select("select content,weibo_id as weiboId,user_id as userId " +
            "from comment " +
            "where id = #{id}" )
    CommentVO1 selectCommentVO1ById1(Integer id);

    @Select("select content,user_id as userId " +
            "from comment " +
            "where id = #{id}" )
    CommentVO2 selectCommentVO2ById2(Integer id);


}
